﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Nancy;
using PlatWL.Data;
using PlatWL.Models;
using Nancy.ModelBinding;
using PlatWL.Services.Services;
using Nancy.Security;

namespace PlatWL.Modules.Admin
{
    public class LoginModule : AdminModule
    {
        public LoginModule(AuthManage service) : base("lg")
        {
            Post["/login"] = p =>
              {
                  var usr = this.Bind<pt_auth_user>();
                  if (usr == null || string.IsNullOrEmpty(usr.UserName) || string.IsNullOrEmpty(usr.Password))
                  {
                      msg.error = "请输入用户名和密码";
                  }
                  else
                  {
                      service.AuthLogin(ref msg, usr.UserName, usr.Password);
                  }
                  return this.Response.AsJson(msg);
              };

            

        }
    }
}